import baseservice from './baseservice.js';
export default {
	getPageData(self, successBack, errorBack) {
		baseservice.getPageData(self, self.apis.bannerPage, self.searchcondition, function(res) {
			self.tableData = self.formattool.trimNull(res.data.list, []);
			self.total = res.data.total;
		});
	},
	getModelData(self, id, successBack, errorBack) {
		baseservice.getModelData(self, self.apis.bannerGet, id);
	},
	handleSave(self, successBack, errorBack) {
		let that = this;
		let rule = [{
			name: 'imgId',
			label: '图片',
			rule: ['validateUpload_']
		}, {
			name: 'seqNo',
			label: '排序编号',
			rule: ['validateEmpty_']
		}];

		if(!self.validatetool.validate(self, self.modelData, rule)) {
			return;
		}
		let requestUrl = self.apis.bannerAdd;
		let msg = '添加成功';
		if(self.modelData.id > 0) {
			requestUrl = self.apis.bannerUpdate;
			msg = '修改成功';
		}
		baseservice.handleSave(self, requestUrl, self.modelData, msg);
	},
	handleDetail(self, row, title) {
		baseservice.showDetail(self, row, title);
	},
	handleDelete(self, id) {
		let that = this;
		baseservice.handleDelete(self, self.apis.bannerDel, id, function(res) {
			that.getPageData(self);
		});

	}
}